include StarRuby
class ResourceManager
  attr_reader :playing_bgm
  def initialize(root_path, texture_path, se_path, bgm_path)
    @root_path = root_path
    @texture_path = texture_path
    @se_path = se_path
    @bgm_path = bgm_path
    @textures = {}
    @playing_bgm = ""
  end
  
  def get_texture(id, cache = true)
    t = Texture.load("#{@root_path}#{@texture_path}#{id}")
    
    if cache
      @textures[id] = t if @textures[id].nil?
      return @textures[id]
    else
      return t
    end
  end

  def play_bgm(id, time = 0)
    @playing_bgm = id
    Audio.play_bgm("#{@root_path}#{@bgm_path}#{id}", :loop => true, :time => time)
  end
  
  def play_se(id)
    Audio.play_se("#{@root_path}#{@se_path}#{id}")
  end
end
